<template>
  <div class="main-container">
    <ChatContainer ref="chatContainer" :mindViewData="mindViewData" />
  </div>
</template>

<script>
import ChatContainer from '../components/ChatContainer.vue'

export default {
  name: 'HomeView',
  components: {
    ChatContainer
  },
  props: {
    mindViewData: {
      type: Object,
      default: null
    }
  },
  methods: {
    receiveMindViewData(data) {
      // 添加防抖处理，防止短时间内多次调用
      if (this._mindViewDebounceTimer) {
        clearTimeout(this._mindViewDebounceTimer);
      }
      
      this._mindViewDebounceTimer = setTimeout(() => {
        console.log('[HomeView] 接收思维导图数据:', data ? '有数据' : '无数据');
        // 这个方法被App.vue调用，用于直接将数据传递给ChatContainer组件
        if (this.$refs.chatContainer) {
          this.$refs.chatContainer.receiveMindViewData(data);
        }
      }, 300); // 300ms的防抖时间
    }
  }
}
</script>

<style>
.main-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f3f5fa;
}
</style> 